package action.front;

import models.${ModelName};

import org.hibernate.criterion.DetachedCriteria;

import action.back.BaseAction;

import com.opensymphony.xwork2.ModelDriven;

public class ${ModelName}Action extends BaseAction implements ModelDriven<${ModelName}>{
	
	private ${ModelName} ${modelName};

	public String list() {
		DetachedCriteria dc = DetachedCriteria.forClass(${ModelName}.class);
		page = commonService.findPage(dc, start, 15);
		return "list";
	}

	public String show() {
		${modelName} = commonService.getById(${ModelName}.class, id);
		return "show";
	}

	public void save() {
		commonService.save(${modelName});
		redirect("${ModelName}!list.action");
	}

	public String edit() {
		${modelName} = commonService.getById(${ModelName}.class, id);
		return "edit";
	}

	public void delete() {
		commonService.delete(commonService.getById(${ModelName}.class, id));
		redirect("${ModelName}!list.action");
	}

	public ${ModelName} get${ModelName}() {
		return ${modelName};
	}

	public void set${ModelName}(${ModelName} ${modelName}) {
		this.${modelName} = ${modelName};
	}
}